{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "16471ad8",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "#从本地仓库中获取到title upstream fixes 以列表的形式返回\n",
    "def getTUFFromLocalRepo(commitId): \n",
    "    return \n",
    "# 从一个issue对象中获取到commit对象\n",
    "def getCommitFromIssue(issue):\n",
    "    commitId = searchCVE(issue.cve)\n",
    "    ret_list = getTUFFromLocalRepo(commitId)\n",
    "    commit = Commit(commitId, ret_list[0], ret_list[1], ret_list[2])\n",
    "    return commit"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "da042980",
   "metadata": {},
   "outputs": [],
   "source": [
    "import service.GiteeService as GiteeService\n",
    "from service.GiteeService import Issue\n",
    "import service.CIService as CIService\n",
    "# issue_list = GiteeService.getIssueList(\"https://gitee.com/openharmony/kernel_linux_5.10/issues?page=3&state=open\")\n",
    "# GiteeService.getCVE(common.getSoup(\"https://gitee.com/openharmony/kernel_linux_5.10/issues/IAOKWW?from=project-issue\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "db1a91df",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Issue('no':#IAQUYA, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】CVE-2024-26950【kernel_linux_5.10】【威胁等级】: 中, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQUYA?from=project-issue, 'state':待办的, 'cve':None, 'targetId':18049330)\n",
      "Issue('no':#IAQTSW, 'title':[安全问题]:[master] 【linux kernel 5.10.210】【必现-3/3】linux kernel组件存在CVE漏洞CVE-2024-42147, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQTSW?from=project-issue, 'state':待办的, 'cve':CVE-2024-42147, 'targetId':18047840)\n",
      "Issue('no':#IAQTS3, 'title':[安全问题]: [master]【linux kernel 5.10.210】【必现-3/3】linux kernel组件存在CVE漏洞CVE-2024-42122, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQTS3?from=project-issue, 'state':待办的, 'cve':CVE-2024-42122, 'targetId':18047811)\n",
      "Issue('no':#IAQTQD, 'title':[安全问题]: [master]【linux kernel 5.10.210】【必现-3/3】linux kernel组件存在CVE漏洞CVE-2024-42121, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQTQD?from=project-issue, 'state':待办的, 'cve':CVE-2024-42121, 'targetId':18047749)\n",
      "Issue('no':#IAQSDX, 'title':[安全问题]: 【安全】【OpenHarmony:kernel_linux_5.10】fuse: use unsigned type for getxattr/listxattr size truncation, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQSDX?from=project-issue, 'state':待办的, 'cve':None, 'targetId':18046005)\n",
      "Issue('no':#IAQSDK, 'title':[安全问题]: 【安全】【OpenHarmony:kernel_linux_5.10】fuse: use unsigned type for getxattr/listxattr size truncation, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQSDK?from=project-issue, 'state':待办的, 'cve':None, 'targetId':18045992)\n",
      "Issue('no':#IAQSD9, 'title':[安全问题]: 【安全】【OpenHarmony:kernel_linux_5.10】media: uvcvideo: Fix integer overflow calculating timestamp, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQSD9?from=project-issue, 'state':待办的, 'cve':None, 'targetId':18045981)\n",
      "Issue('no':#IAQDCF, 'title':[Bug]: Native C++项目系统调用崩溃, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQDCF?from=project-issue, 'state':待办的, 'cve':None, 'targetId':18026511)\n",
      "Issue('no':#IAQ190, 'title':【漏洞】 【OpenHarmony-4.1-Release】 CVE-2024-42302, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ190?from=project-issue, 'state':待办的, 'cve':CVE-2024-42302, 'targetId':18010836)\n",
      "Issue('no':#IAQ18Z, 'title':【漏洞】 【OpenHarmony-4.0-Release】 CVE-2024-42302, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ18Z?from=project-issue, 'state':待办的, 'cve':CVE-2024-42302, 'targetId':18010835)\n",
      "Issue('no':#IAQ18X, 'title':【漏洞】 【master】 CVE-2024-42302, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ18X?from=project-issue, 'state':待办的, 'cve':CVE-2024-42302, 'targetId':18010833)\n",
      "Issue('no':#IAQ18I, 'title':【漏洞】 【OpenHarmony-4.0-Release】 CVE-2024-43892, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ18I?from=project-issue, 'state':待办的, 'cve':CVE-2024-43892, 'targetId':18010818)\n",
      "Issue('no':#IAQ187, 'title':【漏洞】 【OpenHarmony-4.1-Release】 CVE-2024-43892, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ187?from=project-issue, 'state':待办的, 'cve':CVE-2024-43892, 'targetId':18010807)\n",
      "Issue('no':#IAQ17P, 'title':【漏洞】 【master】 CVE-2024-43892, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ17P?from=project-issue, 'state':待办的, 'cve':CVE-2024-43892, 'targetId':18010789)\n",
      "Issue('no':#IAQ16Z, 'title':【漏洞】 【OpenHarmony-4.0-Release】 CVE-2024-44987, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ16Z?from=project-issue, 'state':待办的, 'cve':CVE-2024-44987, 'targetId':18010763)\n",
      "Issue('no':#IAQ16Y, 'title':【漏洞】 【OpenHarmony-4.1-Release】 CVE-2024-44987, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ16Y?from=project-issue, 'state':待办的, 'cve':CVE-2024-44987, 'targetId':18010762)\n",
      "Issue('no':#IAQ16W, 'title':【漏洞】 【master】 CVE-2024-44987, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ16W?from=project-issue, 'state':待办的, 'cve':CVE-2024-44987, 'targetId':18010760)\n",
      "Issue('no':#IAQ16H, 'title':【漏洞】 【OpenHarmony-4.1-Release】 CVE-2022-48877, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ16H?from=project-issue, 'state':待办的, 'cve':CVE-2022-48877, 'targetId':18010745)\n",
      "Issue('no':#IAQ16G, 'title':【漏洞】 【OpenHarmony-4.0-Release】 CVE-2022-48877, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ16G?from=project-issue, 'state':待办的, 'cve':CVE-2022-48877, 'targetId':18010744)\n",
      "Issue('no':#IAQ16F, 'title':【漏洞】 【master】 CVE-2022-48877, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ16F?from=project-issue, 'state':待办的, 'cve':CVE-2022-48877, 'targetId':18010743)\n",
      "Issue('no':#IAQVYZ, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-39487, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQVYZ?from=project-issue, 'state':待办的, 'cve':CVE-2024-39487, 'targetId':18050651)\n",
      "Issue('no':#IAQVXR, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-26851, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQVXR?from=project-issue, 'state':待办的, 'cve':CVE-2024-26851, 'targetId':18050607)\n",
      "Issue('no':#IAQVW5, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-39484, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQVW5?from=project-issue, 'state':待办的, 'cve':CVE-2024-39484, 'targetId':18050549)\n",
      "Issue('no':#IAQVUF, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-39482, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQVUF?from=project-issue, 'state':待办的, 'cve':CVE-2024-39482, 'targetId':18050487)\n",
      "Issue('no':#IAQVTD, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 高 CVE-2024-39480, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQVTD?from=project-issue, 'state':待办的, 'cve':CVE-2024-39480, 'targetId':18050449)\n",
      "Issue('no':#IAQVQF, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-39476, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQVQF?from=project-issue, 'state':待办的, 'cve':CVE-2024-39476, 'targetId':18050343)\n",
      "Issue('no':#IAQVPE, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-39471, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQVPE?from=project-issue, 'state':待办的, 'cve':CVE-2024-39471, 'targetId':18050306)\n",
      "Issue('no':#IAQVND, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-26955, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQVND?from=project-issue, 'state':待办的, 'cve':CVE-2024-26955, 'targetId':18050233)\n",
      "Issue('no':#IAQVLF, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-39301, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQVLF?from=project-issue, 'state':待办的, 'cve':CVE-2024-39301, 'targetId':18050163)\n",
      "Issue('no':#IAQVJA, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-39292, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQVJA?from=project-issue, 'state':待办的, 'cve':CVE-2024-39292, 'targetId':18050086)\n",
      "Issue('no':#IAQVIA, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-38662, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQVIA?from=project-issue, 'state':待办的, 'cve':CVE-2024-38662, 'targetId':18050050)\n",
      "Issue('no':#IAQVFL, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-38661, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQVFL?from=project-issue, 'state':待办的, 'cve':CVE-2024-38661, 'targetId':18049953)\n",
      "Issue('no':#IAQVEW, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-26857, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQVEW?from=project-issue, 'state':待办的, 'cve':CVE-2024-26857, 'targetId':18049928)\n",
      "Issue('no':#IAQVE8, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-38659, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQVE8?from=project-issue, 'state':待办的, 'cve':CVE-2024-38659, 'targetId':18049904)\n",
      "Issue('no':#IAQVBA, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-38635, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQVBA?from=project-issue, 'state':待办的, 'cve':CVE-2024-38635, 'targetId':18049798)\n",
      "Issue('no':#IAQVA1, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-38634, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQVA1?from=project-issue, 'state':待办的, 'cve':CVE-2024-38634, 'targetId':18049753)\n",
      "Issue('no':#IAQV78, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-26951, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQV78?from=project-issue, 'state':待办的, 'cve':CVE-2024-26951, 'targetId':18049652)\n",
      "Issue('no':#IAQV6R, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-38627, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQV6R?from=project-issue, 'state':待办的, 'cve':CVE-2024-38627, 'targetId':18049635)\n",
      "Issue('no':#IAQV2U, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】CVE-2024-26861【kernel_linux_5.10】【威胁等级】: 中 , 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQV2U?from=project-issue, 'state':待办的, 'cve':None, 'targetId':18049494)\n",
      "Issue('no':#IAQV02, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】CVE-2024-26863【kernel_linux_5.10】【威胁等级】: 中 , 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQV02?from=project-issue, 'state':待办的, 'cve':CVE-2024-26863, 'targetId':18049394)\n",
      "Issue('no':#IAQWZF, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中CVE-2024-43829, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQWZF?from=project-issue, 'state':待办的, 'cve':CVE-2024-43829, 'targetId':18051963)\n",
      "Issue('no':#IAQWZE, 'title':[安全问题]: 【安全】【CVE-2024-42301】【OpenHarmony:kernel_linux_5.10 】, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQWZE?from=project-issue, 'state':待办的, 'cve':CVE-2024-42301, 'targetId':18051962)\n",
      "Issue('no':#IAQWY7, 'title':[安全问题]: 【安全】【CVE-2024-27044】【OpenHarmony:kernel_linux_5.10 】, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQWY7?from=project-issue, 'state':待办的, 'cve':CVE-2024-27044, 'targetId':18051919)\n",
      "Issue('no':#IAQWY1, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-43849, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQWY1?from=project-issue, 'state':待办的, 'cve':CVE-2024-43849, 'targetId':18051913)\n",
      "Issue('no':#IAQWWV, 'title':[安全问题]: 【安全】【CVE-2024-27045】【OpenHarmony:kernel_linux_5.10 】, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQWWV?from=project-issue, 'state':待办的, 'cve':CVE-2024-27045, 'targetId':18051871)\n",
      "Issue('no':#IAQWWA, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中CVE-2024-42121, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQWWA?from=project-issue, 'state':待办的, 'cve':CVE-2024-42121, 'targetId':18051850)\n",
      "Issue('no':#IAQWW3, 'title':[安全问题]: 【安全】【CVE-2024-42304】【OpenHarmony:kernel_linux_5.10 】, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQWW3?from=project-issue, 'state':待办的, 'cve':CVE-2024-42304, 'targetId':18051843)\n",
      "Issue('no':#IAQWSZ, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-27047, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQWSZ?from=project-issue, 'state':待办的, 'cve':CVE-2024-27047, 'targetId':18051731)\n",
      "Issue('no':#IAQWRG, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-42306, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQWRG?from=project-issue, 'state':待办的, 'cve':CVE-2024-42306, 'targetId':18051676)\n",
      "Issue('no':#IAQWQL, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-27396, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQWQL?from=project-issue, 'state':待办的, 'cve':CVE-2024-27396, 'targetId':18051645)\n",
      "Issue('no':#IAQWPK, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中CVE-2024-42312, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQWPK?from=project-issue, 'state':待办的, 'cve':CVE-2024-42312, 'targetId':18051608)\n",
      "Issue('no':#IAQWO0, 'title':[安全问题]: [安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-43841, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQWO0?from=project-issue, 'state':待办的, 'cve':CVE-2024-43841, 'targetId':18051552)\n",
      "Issue('no':#IAQWMB, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-43846, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQWMB?from=project-issue, 'state':待办的, 'cve':CVE-2024-43846, 'targetId':18051491)\n",
      "Issue('no':#IAQWKJ, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-43858, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQWKJ?from=project-issue, 'state':待办的, 'cve':CVE-2024-43858, 'targetId':18051427)\n",
      "Issue('no':#IAQWJN, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 未知 CVE-2024-26835, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQWJN?from=project-issue, 'state':待办的, 'cve':CVE-2024-26835, 'targetId':18051395)\n",
      "Issue('no':#IAQWHM, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 ethtool: check device is present when getting link settings, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQWHM?from=project-issue, 'state':待办的, 'cve':None, 'targetId':18051322)\n",
      "Issue('no':#IAQWEY, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中   netfilter: nf_tables_ipv6: consider network offset in netdev/egress v…, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQWEY?from=project-issue, 'state':待办的, 'cve':None, 'targetId':18051226)\n",
      "Issue('no':#IAQW3P, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-26814, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQW3P?from=project-issue, 'state':待办的, 'cve':CVE-2024-26814, 'targetId':18050821)\n",
      "Issue('no':#IAQW2R, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-39489, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQW2R?from=project-issue, 'state':待办的, 'cve':CVE-2024-39489, 'targetId':18050787)\n",
      "Issue('no':#IAQVZQ, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-26956, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQVZQ?from=project-issue, 'state':待办的, 'cve':CVE-2024-26956, 'targetId':18050678)\n",
      "Issue('no':#IARU3T, 'title':[Bug]: 【回合4.0-Release】修复hmdfs跨端访问command参数传递错误问题, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IARU3T?from=project-issue, 'state':待办的, 'cve':None, 'targetId':18094889)\n",
      "Issue('no':#IARTOJ, 'title':[Bug]: 【回合4.1-Release】修复hmdfs跨端访问command参数传递错误问题, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IARTOJ?from=project-issue, 'state':待办的, 'cve':None, 'targetId':18094339)\n",
      "Issue('no':#IARTDP, 'title':[Bug]: 【回合5.0-Release】修复hmdfs跨端访问command参数传递错误问题, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IARTDP?from=project-issue, 'state':待办的, 'cve':None, 'targetId':18093949)\n",
      "Issue('no':#IAR0BT, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【安全】【漏洞编码】:  CVE-2024-41097 , 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAR0BT?from=project-issue, 'state':待办的, 'cve':CVE-2024-41097, 'targetId':18056297)\n",
      "Issue('no':#IAR0B8, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【安全】【漏洞编码】: CVE-2024-42086 , 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAR0B8?from=project-issue, 'state':待办的, 'cve':CVE-2024-42086, 'targetId':18056276)\n",
      "Issue('no':#IAR08A, 'title':[安全问题]:【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】 【漏洞编号】CVE-2024-42104 , 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAR08A?from=project-issue, 'state':待办的, 'cve':CVE-2024-42104, 'targetId':18056170)\n",
      "Issue('no':#IAR06X, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【安全】漏洞CVE-2024-42087, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAR06X?from=project-issue, 'state':待办的, 'cve':CVE-2024-42087, 'targetId':18056121)\n",
      "Issue('no':#IAQXAB, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中CVE-2024-27051, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQXAB?from=project-issue, 'state':待办的, 'cve':CVE-2024-27051, 'targetId':18052355)\n",
      "Issue('no':#IAQX8B, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中CVE-2024-27074, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQX8B?from=project-issue, 'state':待办的, 'cve':CVE-2024-27074, 'targetId':18052283)\n",
      "Issue('no':#IAQX7F, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中CVE-2024-27412, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQX7F?from=project-issue, 'state':待办的, 'cve':CVE-2024-27412, 'targetId':18052251)\n",
      "Issue('no':#IAQX6X, 'title':[安全问题]: 【安全】【CVE-2024-42295】【OpenHarmony:kernel_linux_5.10 】, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQX6X?from=project-issue, 'state':待办的, 'cve':CVE-2024-42295, 'targetId':18052233)\n",
      "Issue('no':#IAQX6U, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中CVE-2024-42311, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQX6U?from=project-issue, 'state':待办的, 'cve':CVE-2024-42311, 'targetId':18052230)\n",
      "Issue('no':#IAQX4G, 'title':[安全问题]: 【安全】【CVE-2024-27001】【OpenHarmony:kernel_linux_5.10 】, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQX4G?from=project-issue, 'state':待办的, 'cve':CVE-2024-27001, 'targetId':18052144)\n",
      "Issue('no':#IAQX3D, 'title':[安全问题]: 【安全】【CVE-2024-27008】【OpenHarmony:kernel_linux_5.10 】, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQX3D?from=project-issue, 'state':待办的, 'cve':CVE-2024-27008, 'targetId':18052105)\n",
      "Issue('no':#IAQX2U, 'title':[安全问题]: 【安全】【CVE-2024-42297】【OpenHarmony:kernel_linux_5.10 】, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQX2U?from=project-issue, 'state':待办的, 'cve':CVE-2024-42297, 'targetId':18052086)\n",
      "Issue('no':#IAQX28, 'title':[安全问题]: 【安全】【CVE-2024-27024】【OpenHarmony:kernel_linux_5.10 】, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQX28?from=project-issue, 'state':待办的, 'cve':CVE-2024-27024, 'targetId':18052064)\n",
      "Issue('no':#IAQX1S, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中CVE-2024-42310, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQX1S?from=project-issue, 'state':待办的, 'cve':CVE-2024-42310, 'targetId':18052048)\n",
      "Issue('no':#IAQX1T, 'title':[安全问题]: 【安全】【CVE-2024-27028】【OpenHarmony:kernel_linux_5.10 】, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQX1T?from=project-issue, 'state':待办的, 'cve':CVE-2024-27028, 'targetId':18052049)\n",
      "Issue('no':#IAQX14, 'title':[安全问题]: 【安全】【CVE-2024-42301】【OpenHarmony:kernel_linux_5.10 】, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQX14?from=project-issue, 'state':待办的, 'cve':CVE-2024-42301, 'targetId':18052024)\n",
      "Issue('no':#IAQX11, 'title':[安全问题]: 【OpenHamrony 5.0.0.41】【内核子系统】【ToC】【RK3568】【必现-10/10】【kernel_linux_5.10】【威胁等级】: 中 CVE-2024-42313, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQX11?from=project-issue, 'state':待办的, 'cve':CVE-2024-42313, 'targetId':18052021)\n"
     ]
    }
   ],
   "source": [
    "# 重新加载GiteeService模块\n",
    "import service.GiteeService as GiteeService\n",
    "from service.GiteeService import Issue\n",
    "import service.CIService as CIService\n",
    "import importlib\n",
    "importlib.reload(GiteeService)\n",
    "issue_list = []\n",
    "gitee_urls = []\n",
    "page_lens = 4\n",
    "for i in range(1, page_lens + 1):\n",
    "    gitee_urls.append('https://gitee.com/openharmony/kernel_linux_5.10/issues?page=' + str(i) + '&state=open')\n",
    "GiteeService.fillInIssueList(gitee_urls, issue_list)\n",
    "for item in issue_list:\n",
    "    print(item)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "987448e7",
   "metadata": {},
   "outputs": [],
   "source": [
    "not '[Bug]: CVE-2024-26686补丁合入引发top命令失败'.startswith(\"[Bug]\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "15c652f4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "#IAQUYA  None\n",
      "#IAQTSW  CVE-2024-42147\n",
      "#IAQTS3  CVE-2024-42122\n",
      "#IAQTQD  CVE-2024-42121\n",
      "#IAQSDX  None\n",
      "#IAQSDK  None\n",
      "#IAQSD9  None\n",
      "#IAQDCF  None\n",
      "#IAQ190  CVE-2024-42302\n",
      "#IAQ18Z  CVE-2024-42302\n",
      "#IAQ18X  CVE-2024-42302\n",
      "#IAQ18I  CVE-2024-43892\n",
      "#IAQ187  CVE-2024-43892\n",
      "#IAQ17P  CVE-2024-43892\n",
      "#IAQ16Z  CVE-2024-44987\n",
      "#IAQ16Y  CVE-2024-44987\n",
      "#IAQ16W  CVE-2024-44987\n",
      "#IAQ16H  CVE-2022-48877\n",
      "#IAQ16G  CVE-2022-48877\n",
      "#IAQ16F  CVE-2022-48877\n",
      "#IAQVYZ  CVE-2024-39487\n",
      "#IAQVXR  CVE-2024-26851\n",
      "#IAQVW5  CVE-2024-39484\n",
      "#IAQVUF  CVE-2024-39482\n",
      "#IAQVTD  CVE-2024-39480\n",
      "#IAQVQF  CVE-2024-39476\n",
      "#IAQVPE  CVE-2024-39471\n",
      "#IAQVND  CVE-2024-26955\n",
      "#IAQVLF  CVE-2024-39301\n",
      "#IAQVJA  CVE-2024-39292\n",
      "#IAQVIA  CVE-2024-38662\n",
      "#IAQVFL  CVE-2024-38661\n",
      "#IAQVEW  CVE-2024-26857\n",
      "#IAQVE8  CVE-2024-38659\n",
      "#IAQVBA  CVE-2024-38635\n",
      "#IAQVA1  CVE-2024-38634\n",
      "#IAQV78  CVE-2024-26951\n",
      "#IAQV6R  CVE-2024-38627\n",
      "#IAQV2U  None\n",
      "#IAQV02  CVE-2024-26863\n",
      "#IAQWZF  CVE-2024-43829\n",
      "#IAQWZE  CVE-2024-42301\n",
      "#IAQWY7  CVE-2024-27044\n",
      "#IAQWY1  CVE-2024-43849\n",
      "#IAQWWV  CVE-2024-27045\n",
      "#IAQWWA  CVE-2024-42121\n",
      "#IAQWW3  CVE-2024-42304\n",
      "#IAQWSZ  CVE-2024-27047\n",
      "#IAQWRG  CVE-2024-42306\n",
      "#IAQWQL  CVE-2024-27396\n",
      "#IAQWPK  CVE-2024-42312\n",
      "#IAQWO0  CVE-2024-43841\n",
      "#IAQWMB  CVE-2024-43846\n",
      "#IAQWKJ  CVE-2024-43858\n",
      "#IAQWJN  CVE-2024-26835\n",
      "#IAQWHM  None\n",
      "#IAQWEY  None\n",
      "#IAQW3P  CVE-2024-26814\n",
      "#IAQW2R  CVE-2024-39489\n",
      "#IAQVZQ  CVE-2024-26956\n",
      "#IARU3T  None\n",
      "#IARTOJ  None\n",
      "#IARTDP  None\n",
      "#IAR0BT  CVE-2024-41097\n",
      "#IAR0B8  CVE-2024-42086\n",
      "#IAR08A  CVE-2024-42104\n",
      "#IAR06X  CVE-2024-42087\n",
      "#IAQXAB  CVE-2024-27051\n",
      "#IAQX8B  CVE-2024-27074\n",
      "#IAQX7F  CVE-2024-27412\n",
      "#IAQX6X  CVE-2024-42295\n",
      "#IAQX6U  CVE-2024-42311\n",
      "#IAQX4G  CVE-2024-27001\n",
      "#IAQX3D  CVE-2024-27008\n",
      "#IAQX2U  CVE-2024-42297\n",
      "#IAQX28  CVE-2024-27024\n",
      "#IAQX1S  CVE-2024-42310\n",
      "#IAQX1T  CVE-2024-27028\n",
      "#IAQX14  CVE-2024-42301\n",
      "#IAQX11  CVE-2024-42313\n"
     ]
    }
   ],
   "source": [
    "for issue in  issue_list:\n",
    "    print(issue.no + \"  \" + str(issue.cve))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "91e6e012",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'issue_list' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[1], line 2\u001b[0m\n\u001b[0;32m      1\u001b[0m CICommentSet \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mset\u001b[39m()\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m issue \u001b[38;5;129;01min\u001b[39;00m issue_list:\n\u001b[0;32m      3\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m issue\u001b[38;5;241m.\u001b[39mcve \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m      4\u001b[0m         \u001b[38;5;28;01mcontinue\u001b[39;00m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'issue_list' is not defined"
     ]
    }
   ],
   "source": [
    "CICommentSet = set()\n",
    "for issue in issue_list:\n",
    "    if issue.cve is None:\n",
    "        continue\n",
    "    tAndR = CIService.getTypeAndReason(issue.cve)\n",
    "    print(tAndR)\n",
    "    t = tAndR['type']\n",
    "    r = tAndR['reaseon']\n",
    "    if t is not None:\n",
    "        comment = str(t)\n",
    "        if r is not None:\n",
    "            comment += \" \" + str(r)\n",
    "        # resp = GiteeService.commentOnIssue(issue.targetId, comment=comment)\n",
    "        GiteeService.collectCIComment(resp, CICommentSet)\n",
    "CICommentSet"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "99cdbad8",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "with open('ci_comment_id.txt', 'a') as f:\n",
    "    for comment_id in CICommentSet :\n",
    "        f.write(str(comment_id) + '\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c3c299ce",
   "metadata": {},
   "outputs": [],
   "source": [
    "import service.CommitService as CommitService\n",
    "from service.CommitService import Commit\n",
    "\n",
    "def printCommitIds(cve, ids_dict):\n",
    "    if ids_dict is None:\n",
    "        return \"\"\n",
    "    ret = '' + cve + \"\\n\"\n",
    "    for k,v in ids_dict.items():\n",
    "        if k == 'title' or k == 'fixes':\n",
    "            continue\n",
    "        ret = ret + str(k) + \" : \" + str(v) + \"\\n\"\n",
    "    return ret\n",
    "commit_list = []\n",
    "\n",
    "# 判断涉及还是不涉及，根据title来判断，输出到文件中\n",
    "judge_list = []\n",
    "\n",
    "# 目前仅仅处理带有cve的issue\n",
    "for issue in issue_list:\n",
    "    cve = issue.cve\n",
    "    if cve is None:\n",
    "        print(\"issue:{}没有cve\\n\".format(issue.no))\n",
    "        continue\n",
    "    commit_ids = CommitService.getCommitIdFromCVE(cve)\n",
    "    if commit_ids is None:\n",
    "        print(\"未找到cve:{}对应的commit\\n\".format(cve))\n",
    "        continue\n",
    "    commit_list.append(Commit(cve, commit_ids['mainline'], commit_ids['stable/5.10'], commit_ids['title'], commit_ids['fixes'], commit_ids['url']))\n",
    "    # print(\"cve : {}\".format(cve))\n",
    "\n",
    "    judge_list.append([cve, commit_ids['stable/5.10']])\n",
    "\n",
    "    # print(printCommitIds(cve, commit_ids))\n",
    "    # resp = GiteeService.commentOnIssue(issue.targetId, printCommitIds(cve, commit_ids))\n",
    "    ####\n",
    "    if commit_ids['all_match_text'] is not None:\n",
    "        print(commit_ids['all_match_text'])\n",
    "        resp = GiteeService.commentOnIssue(issue.targetId, commit_ids['all_match_text'])\n",
    "        GiteeService.collect_comment_id(resp)\n",
    "    ####\n",
    "    # GiteeService.collect_comment_id(resp)\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "b0bc667a",
   "metadata": {},
   "outputs": [],
   "source": [
    "GiteeService.comment_set\n",
    "with open('comment_id.txt', 'a') as f:\n",
    "    for comment_id in GiteeService.comment_set :\n",
    "        f.write(str(comment_id) + '\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "2207e465",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<Response [404]>\n",
      "<Response [200]>\n",
      "<Response [200]>\n"
     ]
    }
   ],
   "source": [
    "for item in GiteeService.comment_set:\n",
    "    print(GiteeService.delete_comment(item))\n",
    "GiteeService.comment_set.clear()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "49f22a07",
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('judge_list.txt', 'w') as f:\n",
    "    for item in judge_list:\n",
    "        f.write(str(item[0]) + \" \" + item[1] + '\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0d08df97",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 重新加载GiteeService模块\n",
    "import importlib\n",
    "importlib.reload(GiteeService)\n",
    "import dao.AnalysisDao as AnalysisDao\n",
    "importlib.reload(AnalysisDao)\n",
    "import sqlite3\n",
    "with sqlite3.connect(\"dao/cve_process.db\") as conn:\n",
    "    for issue in issue_list:\n",
    "        info = \"\"\n",
    "        if issue.cve is None:\n",
    "            print(\"issue:{}没有cve\\n\".format(issue.no))\n",
    "        else:\n",
    "            historyList = GiteeService.getHistoryIssueList(issue.cve)\n",
    "            if len(historyList) == 0:\n",
    "                print(\"cve:{}没有历史issue\\n\".format(issue.cve))\n",
    "            else:\n",
    "                for item in GiteeService.getHistoryIssueList(issue.cve):\n",
    "                    info += str(item) + \"\\n\"\n",
    "                    print(item)\n",
    "        AnalysisDao.update_analysis(conn, issue.no, AnalysisDao.AnalysisType.GITEE, True, info)\n",
    "        print(\"\\n\\n\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0da1a94d",
   "metadata": {},
   "outputs": [],
   "source": [
    "import dao.IssueDao as IssueDao\n",
    "import sqlite3\n",
    "import service.CommitService as CommitService\n",
    "import service.GiteeService as GiteeService\n",
    "from service.GiteeService import Issue\n",
    "\n",
    "# 重新加载dao模块\n",
    "# import importlib\n",
    "# importlib.reload(IssueDao)\n",
    "with sqlite3.connect('dao/cve_process.db') as conn:\n",
    "    for issue in issue_list:\n",
    "        # 如果不存在数据库中，就添加\n",
    "        if IssueDao.is_exist_issue(conn, issue.no):\n",
    "            print(\"issue:{}已经存在数据库中\\n\".format(issue.no))\n",
    "            continue\n",
    "        print(\"issue:{}不存在数据库中\\n\".format(issue.no))\n",
    "        IssueDao.add_issue(conn, issue)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "08ebca57",
   "metadata": {},
   "outputs": [],
   "source": [
    "import sqlite3\n",
    "import dao.IssueDao as IssueDao\n",
    "from service.GiteeService import Issue\n",
    "issue_list = []\n",
    "with sqlite3.connect('dao/cve_process.db') as conn:\n",
    "    all = IssueDao.get_issues(conn)\n",
    "    for item in all:\n",
    "        issue_list.append(Issue.create(item[0], item[1], item[2], item[3], item[4], item[5]))\n",
    "        print(item)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "00c8cffd",
   "metadata": {},
   "outputs": [],
   "source": [
    "len(issue_list)\n",
    "import dao.AnalysisDao as AnalysisDao\n",
    "#reload \n",
    "import importlib\n",
    "importlib.reload(AnalysisDao)\n",
    "with sqlite3.connect('dao/cve_process.db') as conn:\n",
    "    for issue in issue_list:\n",
    "        AnalysisDao.bind_issue(conn, issue.no)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "911a75a5",
   "metadata": {},
   "outputs": [],
   "source": [
    "with sqlite3.connect('dao/cve_process.db') as conn:\n",
    "    a_l = AnalysisDao.get_all_analysis(conn)\n",
    "    for item in a_l:\n",
    "        print(item)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "5b4c3018",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'CVE-2024-45006': 'https://gitee.com/openharmony/kernel_linux_5.10/commit/e54ad4ee7c403aa939c8ef7350dacd77aaf131fd', 'CVE-2024-45006_4.0': 'https://gitee.com/openharmony/kernel_linux_5.10/commit/5a5b3208ed5c4e6787a316ba1ba21866bb4e7fe2', 'CVE-2024-45006_4.1': 'https://gitee.com/openharmony/kernel_linux_5.10/commit/1aa6d7bae4d4c4f9716bd57d2c8d7905500d6700', 'CVE-2024-42276': 'https://gitee.com/openharmony/kernel_linux_5.10/commit/3413e1ca7274ea6812ecf9749b995b81953af384', 'CVE-2024-42276_4.0': 'https://gitee.com/openharmony/kernel_linux_5.10/commit/401754be484f5996b32716f919a694accff9e21d', 'CVE-2024-42276_4.1': 'https://gitee.com/openharmony/kernel_linux_5.10/commit/464631d1668fdce612d6d0b27c2dc59096441cc0', 'CVE-2024-41049': 'https://gitee.com/openharmony/kernel_linux_5.10/commit/10531f96ce2e89baa209c5c14d49d8c6de5f9611', 'CVE-2024-41049_4.0': 'https://gitee.com/openharmony/kernel_linux_5.10/commit/OpenHarmony-4.0-Release^{/CVE-2024-41049}', 'CVE-2024-41049_4.1': 'https://gitee.com/openharmony/kernel_linux_5.10/commit/OpenHarmony-4.1-Release^{/CVE-2024-41049}', 'CVE-2024-43882': 'https://gitee.com/openharmony/kernel_linux_5.10/commit/20623a6b55297a37ba5b348450b7b369508ae0c3', 'CVE-2024-43882_4.0': 'https://gitee.com/openharmony/kernel_linux_5.10/commit/07b85c20a8fb36bbe15c2c1f405847bb0ce78e23', 'CVE-2024-43882_4.1': 'https://gitee.com/openharmony/kernel_linux_5.10/commit/aca7c700268566d98bf6ed38ec8e45b59ad4dda1', 'CVE-2024-43871': 'https://gitee.com/openharmony/kernel_linux_5.10/commit/78aa7320da02c0a6a9f7ffeb5bbf8c8de3a983fa', 'CVE-2024-43871_4.0': 'https://gitee.com/openharmony/kernel_linux_5.10/commit/dd45b3f25dd94db28ef05119f33c7d88b8b40240', 'CVE-2024-43871_4.1': 'https://gitee.com/openharmony/kernel_linux_5.10/commit/2d091e11c623021209010a8bf0bd5ec17addd70b', 'CVE-2024-43856': 'https://gitee.com/openharmony/kernel_linux_5.10/commit/eafd9f9ab86282ba9326860f45722164ac98996d', 'CVE-2024-43856_4.0': 'https://gitee.com/openharmony/kernel_linux_5.10/commit/d2f7b680d17e6ed62fcc3abbf8671c25ee0aec8d', 'CVE-2024-43856_4.1': 'https://gitee.com/openharmony/kernel_linux_5.10/commit/9085f9e7b362ba486b6c6b6332dab486b5bf3f84'}\n",
      "IAQJNW\n",
      "https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQJNW?from=project-issue\n",
      "IAQJNS\n",
      "https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQJNS?from=project-issue\n",
      "IAQJNR\n",
      "https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQJNR?from=project-issue\n",
      "IAQJHW\n",
      "https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQJHW?from=project-issue\n",
      "IAQJHS\n",
      "https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQJHS?from=project-issue\n",
      "IAQJHL\n",
      "https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQJHL?from=project-issue\n",
      "IAQF8J\n",
      "https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQF8J?from=project-issue\n",
      "IAQ15F\n",
      "https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ15F?from=project-issue\n",
      "IAQ15E\n",
      "https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ15E?from=project-issue\n",
      "IAQ15D\n",
      "https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ15D?from=project-issue\n",
      "IAQ158\n",
      "https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ158?from=project-issue\n",
      "IAQ157\n",
      "https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ157?from=project-issue\n",
      "IAQ156\n",
      "https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ156?from=project-issue\n",
      "IAQ12T\n",
      "https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ12T?from=project-issue\n",
      "IAQ12Q\n",
      "https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ12Q?from=project-issue\n",
      "IAQ12K\n",
      "https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ12K?from=project-issue\n",
      "IAQWLQ\n",
      "https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQWLQ?from=project-issue\n"
     ]
    }
   ],
   "source": [
    "# 根据issue的commit_id生成提交的pr commit\n",
    "commit_cve_id = \"\"\"CVE-2024-45006 e54ad4ee7c403aa939c8ef7350dacd77aaf131fd 5a5b3208ed5c4e6787a316ba1ba21866bb4e7fe2 1aa6d7bae4d4c4f9716bd57d2c8d7905500d6700\n",
    "CVE-2024-42276 3413e1ca7274ea6812ecf9749b995b81953af384 401754be484f5996b32716f919a694accff9e21d 464631d1668fdce612d6d0b27c2dc59096441cc0\n",
    "CVE-2024-41049 10531f96ce2e89baa209c5c14d49d8c6de5f9611 OpenHarmony-4.0-Release^{/CVE-2024-41049} OpenHarmony-4.1-Release^{/CVE-2024-41049}\n",
    "CVE-2024-43882 20623a6b55297a37ba5b348450b7b369508ae0c3 07b85c20a8fb36bbe15c2c1f405847bb0ce78e23 aca7c700268566d98bf6ed38ec8e45b59ad4dda1\n",
    "CVE-2024-43871 78aa7320da02c0a6a9f7ffeb5bbf8c8de3a983fa dd45b3f25dd94db28ef05119f33c7d88b8b40240 2d091e11c623021209010a8bf0bd5ec17addd70b\n",
    "CVE-2024-43856 eafd9f9ab86282ba9326860f45722164ac98996d d2f7b680d17e6ed62fcc3abbf8671c25ee0aec8d 9085f9e7b362ba486b6c6b6332dab486b5bf3f84\n",
    "CVE-2024-43828 86dcd194a6cc35a72617f79f6d97080fc8c90db3 7e34d8168cc25401ac21c92ac936ec2dc9d6dd13 29536b6bfb1edf9461bef0eb465545e4901b9127\"\"\"\n",
    "# 读入cve合commit_id的对应关系，生成pr commit，分别对应master 4.0 4.1\n",
    "commit_cve_id = commit_cve_id.split(\"\\n\")\n",
    "commit_cve_dict = {}\n",
    "for i in range(0, len(commit_cve_id) - 1):\n",
    "    l = commit_cve_id[i].split(\" \")\n",
    "    commit_cve_dict[l[0]] = l[1]\n",
    "    commit_cve_dict[l[0] + \"_4.0\"] = l[2]\n",
    "    commit_cve_dict[l[0] + \"_4.1\"] = l[3]\n",
    "# commit_pr = commit_pr.split(\"\\n\")\n",
    "# 将pr链接合并到commit_cve_dict中\n",
    "for (k,v) in commit_cve_dict.items():\n",
    "    commit_cve_dict[k] = \"https://gitee.com/openharmony/kernel_linux_5.10/\"+ \"commit/\" + v\n",
    "# commit_cve_id\n",
    "print(commit_cve_dict)\n",
    "# 根据cve号从issue中获取到对应的targetId，进而评论pr commit\n",
    "import service.GiteeService as GiteeService\n",
    "from service.GiteeService import Issue\n",
    "import service.CIService as CIService\n",
    "for (k, v) in commit_cve_dict.items():\n",
    "    # print(k, v)\n",
    "    for issue in issue_list:\n",
    "        if \"OpenHarmony-4.1-Release\" in issue.title :\n",
    "            if issue.cve == k:\n",
    "                resp = GiteeService.commentOnIssue(issue.targetId, commit_cve_dict[k + \"_4.1\"])\n",
    "                resp1 = GiteeService.commentOnIssue(issue.targetId, \"已合入\")\n",
    "                GiteeService.collect_comment_id(resp)\n",
    "                if resp.status_code == 200:\n",
    "                    print(issue.no[1:])\n",
    "                    print(issue.url)\n",
    "                    GiteeService.modifyIssueState(issue.no[1:])\n",
    "            continue\n",
    "        if \"OpenHarmony-4.0-Release\" in issue.title :\n",
    "            if issue.cve == k:\n",
    "                resp = GiteeService.commentOnIssue(issue.targetId, commit_cve_dict[k + \"_4.0\"])\n",
    "                resp1 = GiteeService.commentOnIssue(issue.targetId, \"已合入\")\n",
    "                GiteeService.collect_comment_id(resp)\n",
    "                if resp.status_code == 200:\n",
    "                    print(issue.no[1:])\n",
    "                    print(issue.url)\n",
    "                    GiteeService.modifyIssueState(issue.no[1:])\n",
    "            continue\n",
    "        if issue.cve == k:\n",
    "            resp = GiteeService.commentOnIssue(issue.targetId, v)\n",
    "            resp1 = GiteeService.commentOnIssue(issue.targetId, \"已合入\")\n",
    "            GiteeService.collect_comment_id(resp)\n",
    "            GiteeService.collect_comment_id(resp1)\n",
    "            if resp.status_code == 200:\n",
    "                print(issue.no[1:])\n",
    "                print(issue.url)\n",
    "                GiteeService.modifyIssueState(issue.no[1:])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cc4936eb",
   "metadata": {},
   "outputs": [],
   "source": [
    "issue_nos = \"\"\"#IAP0JD\n",
    "#IAP0IQ\n",
    "#IAP0GO\n",
    "#IAP0FQ\"\"\"\n",
    "issue_nos = issue_nos.split(\"\\n\")\n",
    "# 根据issue号从issue中获取到对应的targetId，进而评论pr commit\n",
    "import service.GiteeService as GiteeService\n",
    "from service.GiteeService import Issue\n",
    "import service.CIService as CIService\n",
    "for issue_no in issue_nos:\n",
    "    for issue in issue_list:\n",
    "        if issue_no == issue.no:\n",
    "            resp = GiteeService.commentOnIssue(issue.targetId, 'https://gitee.com/openharmony/kernel_linux_5.10/pulls/1592')\n",
    "            GiteeService.collect_comment_id(resp)\n",
    "            print(issue.url)\n",
    "            if resp.status_code == 200:\n",
    "                GiteeService.modifyIssueState(issue_no[1:])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "677298c2",
   "metadata": {},
   "outputs": [],
   "source": [
    "cve_str = \"\"\"CVE-2024-44969\n",
    "CVE-2023-52901\n",
    "CVE-2024-42312\n",
    "CVE-2024-43834\n",
    "CVE-2024-43830\n",
    "CVE-2024-42292\n",
    "CVE-2024-43879\n",
    "CVE-2024-42304\n",
    "CVE-2024-43880\n",
    "CVE-2023-52893\n",
    "CVE-2024-42281\n",
    "CVE-2023-52894\n",
    "CVE-2023-52898\n",
    "CVE-2024-44965\n",
    "CVE-2022-48896\"\"\"\n",
    "cve_str = cve_str.split(\"\\n\")\n",
    "import service.GiteeService as GiteeService\n",
    "import service.CIService as CIService\n",
    "CICommentSet = set()\n",
    "for cve in cve_str:\n",
    "    if cve is None:\n",
    "        continue\n",
    "    tAndR = CIService.getTypeAndReason(cve)\n",
    "    print(tAndR)\n",
    "    t = tAndR['type']\n",
    "    r = tAndR['reaseon']\n",
    "    if t is not None:\n",
    "        comment = str(t)\n",
    "        if r is not None:\n",
    "            comment += \" \" + str(r)\n",
    "        # resp = GiteeService.commentOnIssue(issue.targetId, comment=comment)\n",
    "        print(comment)\n",
    "        # GiteeService.collectCIComment(resp, CICommentSet)\n",
    "CICommentSet\n",
    "\n",
    "# for cve in cve_str:\n",
    "#     info = \"\"\n",
    "#     if cve is None:\n",
    "#         print(\"issue:{}没有cve\\n\".format(issue.no))\n",
    "#     else:\n",
    "#         historyList = GiteeService.getHistoryIssueList(cve)\n",
    "#         if len(historyList) == 0:\n",
    "#             print(\"cve:{}没有历史issue\\n\".format(cve))\n",
    "#         else:\n",
    "#             for item in GiteeService.getHistoryIssueList(cve):\n",
    "#                 info += str(item) + \"\\n\"\n",
    "#                 print(item)\n",
    "#     # AnalysisDao.update_analysis(conn, issue.no, AnalysisDao.AnalysisType.GITEE, True, info)\n",
    "#     print(\"\\n\\n\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
